<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
//引入验证码类


//第三方组件安装验证码
use Gregwar\Captcha\CaptchaBuilder;
use Gregwar\Captcha\PhraseBuilder;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use App\Http\Model\User;
class LoginController extends Controller
{
    //
    public function index()
    {
    	return view('admin.login');
    }
	 //登录处理
    public function dologin()
    {
		
		//dd(Input::all());
        //接受用户传过来的参数
        $input = Input::except('_token');
 
        //验证用户名
        $user = User::where('user_name',$input['user_name'])->first();
        if(!$user){
            return back()->with('error','此用户不存在');
        }

        //验证密码
       //if($input['user_pass'] != Crypt::decrypt($user->user_pass)){
		if($input['user_pass'] != $user->user_pass){
           return back()->with('error','密码不正确');
		}
        Session::put('user',$user);
	   //验证输出次数
	   

        Session::put('user',$user);
        //重定向到后台首页
        return redirect('admin');
	   


    }
}
